home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT37.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.1 KB  |  67 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 37                         
  5.                                                                               
  6.  Demonstrates the use of msetxy. Press a button to end the program.          
  7.                                                                               
  8.  *** PROJECT ***                                                             
  9.  This program requires the file WGT5_WC.LIB to be linked.                      ║
  10.                                                                               
  11.  *** DATA FILES ***                                                          
  12.  None.                                                                       
  13.                                                            WATCOM C++ VERSION 
  14. ==============================================================================
  15. */
  16.  
  17. #include <wgt5.h>
  18.  
  19. short x = 160;
  20. short y = 100;
  21. short xdir = 1;
  22. short ydir = 1;
  23. short oldmode;
  24.  
  25. void main(void)
  26. {
  27.  if ( !vgadetected () )
  28.   {
  29.     printf("Error - VGA card required for any WGT program.\n");
  30.     exit (0);
  31.   }
  32.  
  33.   printf ("WGT Example #37\n\n");
  34.   printf ("Try struggling with the mouse to control where it moves.\n");
  35.   printf ("MSETXY is used to force the cursor's position as it bounces around the screen.\n");
  36.   printf ("Click the mouse button to end the program.\n");
  37.   printf ("\n\nPress any key to continue.\n");
  38.   getch ();
  39.  
  40.   oldmode = wgetmode ();         /* Gets the current mode */
  41.   vga256 ();                     /* Initialize graphics mode */
  42.  
  43.  minit ();
  44.  mon ();
  45.  
  46.  do {
  47.    x += xdir;
  48.    y += ydir;
  49.    if (x < 1)
  50.      xdir = 1;
  51.    else if (x > 318)
  52.      xdir = -1;
  53.  
  54.    if (y < 1) 
  55.      ydir = 1;
  56.    else if (y > 198) 
  57.      ydir = -1;
  58.  
  59.    msetxy(x,y);
  60.    wretrace ();
  61.  } while (!mouse.but);
  62.  mdeinit ();                   /* Deinitialize the mouse handler */
  63.  
  64.  wsetmode (oldmode);
  65. }
  66.  
  67.